//
//  TitleAndContentCell.m
//  Estate
//
//  Created by heyong on 2016/10/31.
//  Copyright © 2016年 ttsx. All rights reserved.
//
#define kHGap           (12)

#import "TitleAndContentCell.h"

@implementation TitleAndContentCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        self.accessoryType = UITableViewCellAccessoryNone;
        if (!_titleL) {
            _titleL = [[UILabel alloc] init];
            _titleL.textAlignment = NSTextAlignmentLeft;
            _titleL.font = [UIFont systemFontOfSize:16*BIZ];
            _titleL.textColor = UIColorFromRGB(0x787878);
            _titleL.numberOfLines = 0;
            _titleL.lineBreakMode = NSLineBreakByTruncatingTail;
            [self.contentView addSubview:_titleL];
        }
    }
    return self;
}
- (void)layoutSubviews{
    [super layoutSubviews];
    
}

- (void)setTitleContent:(NSString *)title
{
    _titleL.text = title;
    _titleL.frame=CGRectMake(kPaddingLeftWidth,kHGap , (kScreen_Width - kPaddingLeftWidth*2), [TitleAndContentCell cellHeightWithObj:_titleL.text ]);
}

+ (CGFloat)cellHeightWithObj:(NSString *)string{
    CGFloat cellHeight = 44;
    cellHeight = [string  boundingRectWithSize:CGSizeMake((kScreen_Width - kPaddingLeftWidth*2), 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:16*BIZ] forKey:NSFontAttributeName] context:nil].size.height;
    return cellHeight;
}

+ (CGFloat)cellContentHeight:(NSString *)contents
{
    return  kHGap*2  + [TitleAndContentCell cellHeightWithObj:contents];
}

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    TitleAndContentCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_MebCenterFunctionCell];
    if (cell == nil) {
        cell = [[TitleAndContentCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellIdentifier_MebCenterFunctionCell];
    }
    return cell;
}

@end
